package com.yl.core.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;

@Slf4j
public class MyApplicationEnvironmentPreparedListener implements ApplicationListener<ApplicationEnvironmentPreparedEvent> {

    /**
     * spring boot对应Enviroment已经准备完毕，但此时上下文context还没有创建。
     * 在该监听中获取到ConfigurableEnvironment后可以对配置信息做操作，
     * 例如：修改默认的配置信息，增加额外的配置信息等等
     * @param event
     */
    @Override
    public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
        //log.error("springboot对应Environment已经准备完毕");
        System.out.println("ApplicationEnvironmentPreparedEvent事件发布：" + event.getTimestamp());
    }
}
